/**
 * @param {number[][]} mat
 * @return {number}
 */
 var numSpecial = function(mat) {
  let row = mat.length
  let col = mat[0].length
  let count = 0
  let hash = {},arr =[]
  for (let i = 0; i < row; i++) {
    for(let j=0;j<col;j++){
      if(mat[i][j]==1){

        hash['row'+i] = hash['row'+i]>0?hash['row'+i]+1:1
        hash['col'+j] = hash['col'+j]>0?hash['col'+j]+1:1

        if( hash['row'+i] ==1 &&  hash['col'+j]==1) arr.push([i,j])
      }
    }
    
  }

  for(let i=0;i<arr.length;i++){
    if(hash['row'+arr[i][0]]==1&& hash['col'+arr[i][1]]==1) count++
  }

  return count
};

numSpecial([[0,0,0,0,0],[1,0,0,0,0],[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,1]])